﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxCallback;
using TireService.Data;

namespace TireService.Website
{
    public partial class Tilbud : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// Callback function that send email to us
        /// </summary>
        protected void callBackSendRequest_Callback(object sender, CallbackEventArgs e)
        {
            try
            {
                // Get input value (0: email, 1: registrationnumber, 2: rimtype, 3: subscription, 4: message)
                string[] param = e.Parameter.Split('|');

                string rimtype = "Alu fælge";
                if (Convert.ToInt32(param[2]) == 1)
	            {
                    rimtype = "Stål fælge";
	            }

                string subscription = "Bronze abonnement";
                if (Convert.ToInt32(param[3]) == 1)
                {
                    subscription = "BronzePlus abonnement";
                }

                // Prepare email
                EmailNotificationServices emailService = new EmailNotificationServices();

                // Send email to finance with order details
                emailService.SendInternalEmailNotification("Salg - forespørgsel på tilbud", "Email: " + param[0].ToString() + "<br>Reg.nr: " + param[1].ToString() + "<br>Fælge: " + rimtype + "<br>Abonnement: " + subscription + "<br>Besked: " + param[4].ToString(), "salg@mobilhjulskift.dk");
                

            }
            catch (Exception ex)
            {
                // Error
                throw new ArgumentException(ex.Message);
            }
        }
    }
}